<?php
namespace App\Services\Sms\Sms;
use App\Models\Sms\SmsLog;
use App\Services\Sms\ValidateSmsLog;
use App\Services\Manage\ManageIndex;
use Illuminate\Support\Facades\DB;
/**
 * @Author: 蒋哲
 * @Date:   2017-05-27 16:25:06
 * @Last Modified by:   ws
 * @Last Modified time: 2018-06-12 
 */ 
class SmsLogLogic 
{
    /*添加一条 "短信发送记录" */
    /*public function addLog($data)
    {
        return $this->model($this->smsLogModel)->save($data);
    }*/

    /*添加多条发送记录*/
    /*public function batchAddLog($data)
    {
        return $this->model($this->smsLogModel)->saveAll($data);
    }*/

    /*获取短信发送记录列表*/
    public function logList($data): array 
    {
        if($data['status'] !== ''){
            $data['status'] == 1 && $_where[] = ['status', '=', 0];
            $data['status'] == 0 && $_where[] = ['status', '<>', 0];
        }
        $data['keywords'] !== '' && $_where[] = ['mobile','like','%'.$data['keywords'].'%'];
        if(!isset($_where)){
            $res =  SmsLog::orderBy('id', 'desc')->paginate($data['listRows'], null, null, $data['page'])
                     ->toArray(); 
            }else{
            $res =  SmsLog::where($_where)->orderBy('id', 'desc')->paginate($data['listRows'], null, null, $data['page'])
                     ->toArray(); 
            }
        return auto_return_page($res);
    }
}